package com.xgk.boot.module.core.enums.biz;

import cn.hutool.core.util.ArrayUtil;
import com.xgk.boot.framework.common.core.ArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 物流状态：
 *  Unallocated FindingDriver DriverAllocated EnrouteToPickup ArrivedAtPickup EnrouteToDelivery ArrivedAtDelivery Completed Cancelled
 */
@AllArgsConstructor
@Getter
public enum LogisticsStatusEnum implements ArrayValuable<Integer> {

    Unallocated(0, "Unallocated"),
    FindingDriver(1, "FindingDriver"),
    DriverAllocated(2, "DriverAllocated"),
    EnrouteToPickup(3, "EnrouteToPickup"),
    ArrivedAtPickup(4, "ArrivedAtPickup"),
    EnrouteToDelivery(5, "EnrouteToDelivery"),
    ArrivedAtDelivery(6, "ArrivedAtDelivery"),
    Completed(7, "Completed"),// 面
    Cancelled(99, "Cancelled"); // 面向 b 端，管理后台

    public static final Integer[] ARRAYS =  Arrays.stream(values()).map(LogisticsStatusEnum::getValue).toArray(Integer[]::new);

    /**
     * 类型
     */
    private final Integer value;
    /**
     * 类型名
     */
    private final String name;

    public static LogisticsStatusEnum valueOf(Integer value) {
        return ArrayUtil.firstMatch(userType -> userType.getValue().equals(value), LogisticsStatusEnum.values());
    }

    @Override
    public Integer[] array() {
        return ARRAYS;
    }
}
